package com.dailyblue.java.standard.network.socket.tcp;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.Socket;

// 模拟客户端
public class Clients {
    public static void main(String[] args) throws Exception{
        // 产生客户端的端点(套接字)提供服务器IP和port
        String ip = "127.0.0.1";
        int port = 8899;
        Socket socket = new Socket(ip,port);
        // 模拟客户端接收服务器的消息
        InputStream in = socket.getInputStream();
        Reader reader = new InputStreamReader(in);
        BufferedReader br = new BufferedReader(reader);
        String message = br.readLine();
        System.out.println("客户端："+message);
    }
}
